package org.xbzheng.restful_study.web;

import org.xbzheng.restful_study.util.ResponseEntity;
import org.xbzheng.restful_study.util.ResponseError;
import org.xbzheng.restful_study.util.ResponseStatus;

/**
 * Created by Administrator on 2016/11/1.
 */
public class BaseController {

    public ResponseEntity getResult(int errorCode, String desc){
        ResponseError error = new ResponseError(errorCode, desc);

        ResponseEntity entity = new ResponseEntity();
        entity.setStatus(ResponseStatus.ERROR);

        entity.setError(error);
        return entity;
    }

    public ResponseEntity getResult(Object[] data){
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setStatus(ResponseStatus.OK);
        responseEntity.setData(data);
        responseEntity.setError(null);

        return responseEntity;
    }
}
